<?php
    /**
     * Form to get input for Earn Revenue Report
     */
    class EarnedRevenueReportForm extends CFormModel
    {

        public $startDate;
        public $endDate;
        protected $reportData;

        public function rules()
        {
            return array(
                array('startDate,endDate', 'date', 'format'=>'dd-MM-yyyy')
            );
        }
        
        public function attributeLabels()
        {
            return array(
                'startDate'=>'Start Date',
                'endDate'=>'End Date'
            );
        }
        public function makeReportData()
        {
            if ($this->validate())
            {
                $startDate = DateHelper::convertDate('Y-m-d', $this->startDate);
                $endDate = DateHelper::convertDate('Y-m-d', $this->endDate);
                $this->reportData = EarnedRevenueReportUtil::getReportData($startDate, $endDate);
                return $this->reportData;
            }
            
            return false;
        }

        public function getReportData()
        {
            if($this->reportData == null){
                $this->reportData = $this->makeReportData();
            }
            return $this->reportData;
        }

    }
